
package com.xiyuan.smartutils.client.ws.core.handler;

import com.xiyuan.smartutils.client.ws.client.WebSocketClient;
import com.xiyuan.smartutils.client.exception.WebSocketException;

import java.nio.ByteBuffer;

/**
 * The class StreamHandler
 *
 * @author xiyuan 2022-07-10 @version 1.0.0 新建或整理
 */
public interface StreamHandler {
    
    /**
     * Next handshake upstream handler.
     *
     * @param ws     the ws
     * @param buffer the buffer
     * @throws WebSocketException
     */
    public void writeHandshake(WebSocketClient ws, ByteBuffer buffer) throws WebSocketException;
    
    /**
     * Next handshake downstream handler.
     *
     * @param ws     the ws
     * @param buffer the buffer
     * @throws WebSocketException the web socket exception
     */
    public void readHandshake(WebSocketClient ws, ByteBuffer buffer) throws WebSocketException;
    
    /**
     * Next upstream handler.
     *
     * @param ws     the ws
     * @param buffer the buffer
     * @throws WebSocketException the web socket exception
     */
    public void write(WebSocketClient ws, ByteBuffer buffer) throws WebSocketException;
    
    /**
     * Next downstream handler.
     *
     * @param ws     the ws
     * @param buffer the buffer
     * @throws WebSocketException the web socket exception
     */
    public void read(WebSocketClient ws, ByteBuffer buffer) throws WebSocketException;
}
